<template>
<div class="content">
<form class="mui-input-group">
    <div class="mui-input-row">
        <label>用户名</label>
    <input type="text" class="mui-input-clear" placeholder="请输入用户名" v-model="name">
    </div>
    <div class="mui-input-row">
        <label>密码</label>
        <input type="password" class="mui-input-password" placeholder="请输入密码" v-model="pwd">
    </div>
    <div class="mui-input-row">
        <label>昵称</label>
        <input type="text" class="mui-input-clear" placeholder="请输入昵称" v-model="nick">
    </div>
    <div class="mui-button-row">
        <button type="button" class="mui-btn mui-btn-primary" @click="yes">确认</button>
        <button type="button" class="mui-btn mui-btn-danger" @click="back">返回</button>
    </div>
    </form>
</div>
</template>
<script>
import mui from'../../../lib/MUI/js/mui.min.js'
import { Toast } from 'mint-ui';
import { MessageBox } from 'mint-ui';
export default {
    data(){
        return{
            name:"",
            pwd:"",
            nick:"",
        }
    },
    methods:{
        back(){
            this.$router.go(-1)
        },
        yes(){
            if(!this.name||!this.pwd||!this.nick)
            {
                Toast('请填写以上内容');
                this.name="";
                this.pwd="";
                this.nick="";
            }
            else{
                this.$http.post('http://192.168.0.197:88/regist',{name:this.name,pwd:this.pwd,nick:this.nick},{emulateJSON:true}).then(function(res){
                console.log(res.body.data);
                if(res.body.data=="nick/name已存在")
                {
                    MessageBox('账号已存在,注册失败')
                }
                else{
                Toast('注册成功');
                this.name="";
                this.pwd="";
                this.nick="";
                this.$router.go(-1)                    
                }
                },function(res){
                    console.log(res.status);
                });


            }

        }
    },
}
</script>
<style scoped>

</style>